package org.openea.eap.module.obpm.service.custsql.impl;

import org.openbpm.base.core.util.StringUtil;
import org.openbpm.base.manager.impl.BaseManager;
import org.openea.eap.module.obpm.dao.custsql.FormCustSqlRelationDao;
import org.openea.eap.module.obpm.service.custsql.FormCustSqlRelationManager;
import org.openea.eap.module.obpm.model.custsql.FormCustSqlRelation;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service("formCustSqlRelationManager")
public class FormCustSqlRelationManagerImpl
  extends BaseManager<String, FormCustSqlRelation>
  implements FormCustSqlRelationManager
{
  @Resource
  FormCustSqlRelationDao formCustSqlRelationDao;

  public FormCustSqlRelation getByFormKey(String formKey) {
    if (StringUtil.isEmpty(formKey)) return null;
    // fix, 避免出现formKey重复问题
    List<FormCustSqlRelation> list = this.formCustSqlRelationDao.getByFormKey(formKey);
    if(list==null || list.isEmpty()){
      return null;
    }else{
      return list.get(0);
    }
  }



  public void removeByListId(String id) { this.formCustSqlRelationDao.removeByListId(id); }
}
